using System;

namespace FreeFlow
{
	/// <summary>
	/// Helper class for alerts.
	/// </summary>
	public static class AlertHelper
	{
    /// <summary>
    /// Gets the string used in the database to denote the specified alert type.
    /// </summary>
    /// <param name="alertType">Type of alert.</param>
    /// <returns>The string used in the database to denote the specified alert type</returns>
    public static string AlertTypeString(AlertType alertType)
    {
      switch (alertType)
      {
        case AlertType.ToDo : return " ";
        case AlertType.Watch : return "!";
        case AlertType.Deletion : return "~";
        default : throw new FreeFlowException("Unrecognized alert type - " + alertType);
      }
    }

    /// <summary>
    /// Gets the type of an alert from the string used to represent it in the database.
    /// </summary>
    /// <param name="alertTypeString">The alert type string.</param>
    public static AlertType AlertTypeFromString(string alertTypeString)
    {
      switch (alertTypeString)
      {
        case " " : return AlertType.ToDo;
        case "!" : return AlertType.Watch;
        case "~" : return AlertType.Deletion;
        default : throw new FreeFlowException("Unrecognized alert type string - " + alertTypeString);
      }
    }
	}
}
